package com.emin.platform.subjectcenter.api;

import com.emin.base.exception.EminException;
import com.emin.platform.subjectcenter.common.response.ResponseBack;
import com.emin.platform.subjectcenter.service.IndustoryService;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import static com.emin.platform.subjectcenter.exception.ExceptionCode.SYSTEM_ERROR;

/**
 * 行业Controller
 *
 * @author Jack
 * @version V1.0
 * @Title:
 * @Description: 用于行业相关操作
 * @date 2017/10/25 17:06
 */
@Controller
@RequestMapping("/industory")
public class IndustoryController {

    @Autowired
    private IndustoryService industoryService;


    @RequestMapping(value = "/getIndustorys", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询所有的行业信息", tags = {"主体中心基本信息API"}, httpMethod = "GET",
            produces = "application/json")
    public ResponseBack<JSONArray> getIndustorys() {
        try {
            return industoryService.getIndustorys();
        } catch (EminException e) {
            return ResponseBack.error(e);
        } catch (Exception e) {
            return ResponseBack.error(SYSTEM_ERROR);
        }
    }

}
